package util;

import java.util.HashMap;
import java.util.Map;

public class MovieStorage {
    static Map<Integer, Movie> movies = new HashMap<Integer, Movie>();

    static {
        add(new Movie(1, "Sholay", "1975", "Ramesh Sippy"));
        add(new Movie(2, "Social Network", "2010", "Facebook Story", 7));

    }

    public static Movie get(int id) {
        return movies.get(id);
    }

    public static void add(Movie movie) {
        movies.put(movie.getId(), movie);
    }

    public static String showMoviesList() {
        String moviesList = Movie.getMovieTable() + "\n";
        for (int id = 1; id <= movies.size(); id++) {
            moviesList += movies.get(id) + "\n";
        }
        return moviesList;
    }

    public static void flush() {
        movies = new HashMap<Integer, Movie>();
    }
}
